home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 034a / twview82.zip / PORTSTAT.INC < prev    next >
Text File  |  1991-02-04  |  2KB  |  79 lines

  1. function FindPortSlot( var top : PortIndex; which : sector ) : PortIndex;
  2. {If which is already in the data base, return that location.  If not, then if
  3. we are full, return 0; otherwise add one to top and return it. }
  4. var
  5.   i : portIndex;
  6.   found : boolean;
  7. begin
  8.   found := false;
  9.   if top > 0 then
  10.     for i := 1 to top do
  11.       if space.ports.data[ i ].where = which then
  12.         begin
  13.           FindPortSlot := i;
  14.           found := true;
  15.         end;
  16.   if not found then
  17.     if top = MaxPorts then
  18.       FindPortSlot := 0
  19.     else
  20.       begin
  21.         top := top + 1;
  22.         FindPortSlot := top;
  23.       end; {else}
  24. end; {FindPortSlot}
  25.  
  26. procedure GetPortStatus(     s        : sector;
  27.                          var PortType : stuff;
  28.                              line     : string;
  29.                          var ThePorts : Portlist );
  30. var
  31.   ch : char;
  32.   pa : GoodsArray;
  33.   NewSlot : PortIndex;
  34. begin
  35.   if pos( 'You can buy', line ) > 0 then
  36.     PortType := Class0
  37.   else
  38.     begin              
  39.       readln( f, line );  { blank }
  40.       readln( f, line );  { items }
  41.       readln( f, line );  { ----- }
  42.       skip( f, 11 );
  43.       read( f, ch );
  44.       skip( f, 8 );
  45.       readln( f, pa[ Fuel ] );
  46.       if ch = 'B' then
  47.         begin
  48.           PortType := 0;
  49.           pa[ Fuel ] := -pa[ fuel ];
  50.         end {if}
  51.       else
  52.         PortType := 1;
  53.       skip( f, 11 );
  54.       read( f, ch );
  55.       skip( f, 8 );
  56.       readln( f, pa[ Organics ] );
  57.       if ch = 'B' then
  58.         pa[ Organics ] := -pa[ Organics ]
  59.       else
  60.         PortType := PortType + 2;
  61.       skip( f, 11 );
  62.       read( f, ch );
  63.       skip( f, 8 );
  64.       readln( f, pa[ Equipment ] );
  65.       if ch = 'B' then
  66.         pa[ Equipment ] := -pa[ Equipment ]
  67.       else
  68.         PortType := PortType + 4;
  69.       NewSlot := FindPortSlot( ThePorts.top, s );
  70.       if NewSlot = 0 then
  71.         writeln('Can''t record all of our port info!')
  72.       else
  73.         begin
  74.           ThePorts.data[ NewSlot ].where := s;
  75.           ThePorts.data[ NewSlot ].amts := pa;
  76.         end; {else}
  77.     end; {else}
  78. end; {GetPortStatus}
  79.